import cv2

img = cv2.imread("C:\\Users\\86191\\Pictures\\Saved Pictures\\Camera Roll\\yy.jpg")
# 灰度图
img1 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# 二值化
# ret,dst= cv2.threshold(img1,60,255,cv2.THRESH_BINARY)

# 自适应阈值化
dst = cv2.adaptiveThreshold(img1,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,3,0)
cv2.imshow("binary",dst)
cv2.waitKey(0)